package com.ferry.taskflow.taskFlow.tx;

import com.ferry.taskflow.taskFlow.base.IdAble;

import java.util.List;

/**
 * Created by daiyong
 */
public class TxStage extends IdAble {

	private TxFlow txFlow = null;

	private List<TxTaskExecutor> executors = Lists.newArrayList();

	private TxStage() {}

	public TxStage addTask(Task task) {
		TxTaskExecutor txTaskExecutor = new TxTaskExecutor((TxTask) task);
		txTaskExecutor.txStage(this);
		executors.add(txTaskExecutor);
		return this;
	}

	public List<TxTaskExecutor> executors() {
		return this.executors;
	}

	public static TxStage create() {
		return new TxStage();
	}

	public TxStage txFlow(TxFlow txFlow) {
		this.txFlow = txFlow;
		return this;
	}

	public TxFlow txFlow() {
		return txFlow;
	}
}
